<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
	<%@include file="/WEB-INF/jsp/common/taglibs.jsp" %>
</head>
<body class="no-skin">
	<!-- 查询区域start -->
	<div>
		<table width="100%" border="0">
			<tr>
				<td width="9%" align="right" nowrap="nowrap"><strong>部门代码：</strong>
				<input type="hidden" id="orgCodeSearch" value="${orgCode}"></td>
				<td width="22%"><input name="deptCode" type="text" id="deptCodeSearch"></td>
				<td width="9%" align="right" nowrap="nowrap"><strong>部门名称：</strong></td>
				<td width="22%"><input name="deptName" type="text" id="deptNameSearch"></td>
				<td width="39%">
					<button class="btn btn-sm btn-info" type="button" onclick="initTable();">
					   <i class="ace-icon glyphicon glyphicon-search bigger-110"></i>查 询
					</button>
					<button class="btn btn-sm btn-warning" type="button" onclick="toAddAuthDept();" >
						<i class="ace-icon glyphicon glyphicon-plus bigger-110"></i>新 增
					</button>
				</td>
			</tr>
		</table>
	</div>
	<!--查询区域end-->
	<div id="faq-tab-1" class="tab-pane fade in active">
		<!--查询结果-->
		<div style="overflow-x:auto;  margin-top:10px">
			<table id="org_sample_table" class="table table-striped table-bordered table-hover" style="margin:0; "  >
				<caption></caption>
				<thead>
					<tr>
						<th nowrap="nowrap" class="center"> 序号 </th>
						<th nowrap="nowrap">部门代码</th>
				        <th nowrap="nowrap" >部门名称</th>
				        <%--<th nowrap="nowrap">机构代码</th>--%>
				        <th nowrap="nowrap">备注</th>
				        <%--<th nowrap="nowrap">状态</th>--%>
				        <th nowrap="nowrap">操作</th>
				    </tr>
				</thead>
				<tbody>
		      	</tbody>
		   </table>
		</div>
	</div>
	<script type="text/javascript">
		jQuery(function ($) {
			initTable();
		});

		//初始化表格
		function initTable() {
			$("#org_sample_table").dataTable().fnDestroy();
			json = {};
			json.showLineNuber = true;
			json.id = "org_sample_table";
			json.url = contextPath + '/auth/authdept/getAuthDeptData.json';
//			json.bLengthChange = true;
//			json.pagesize = 20;
			//查询条件参数
			json.param = [
				{"name": "orgCode", "value": $("#orgCodeSearch").val()},
				{"name": "deptCode", "value": $.trim($("#deptCodeSearch").val())},
				{"name": "deptName", "value": $.trim($("#deptNameSearch").val())}
			];
			//返回数据格式列
			json.columns = [
				{"sWidth": "20px", "sClass": "text-center"},
				{"mData": "deptCode", "sWidth": "100px", "sClass": "text-center"},
				{"mData": "deptName", "sWidth": "100px", "sClass": "text-center"},
//				{"mData": "orgCode", "sWidth": "100px", "sClass": "text-center"},
				{"mData": "remark", "sWidth": "100px", "sClass": "text-center"},
//				{
//					"mData": "isDel", "sWidth": "100px", "sClass": "text-center",
//					"mRender": function (data, type, row) {
//						if (data == 0) {
//							return '&nbsp;&nbsp;&nbsp;&nbsp;有效&nbsp;&nbsp;&nbsp;&nbsp;';
//						} else {
//							return '&nbsp;&nbsp;&nbsp;&nbsp;无效&nbsp;&nbsp;&nbsp;&nbsp;';
//						}
//					}
//				},
				{
					"mData": "deptId", "sWidth": "100px", "sClass": "text-center",
					"mRender": function (data, type, row) {
						if (data) {
							var htmlText =
									'&nbsp;&nbsp;<a style="color:#428bca" href="'+contextPath +'/auth/authdept/toEditAuthDept.htm?orgCode=${orgCode}&operateType=2&deptId=' + data + '" >修改</a>&nbsp;&nbsp;' +
									'<a style="color:#428bca" href="javascript:deleteAuthDept(' + data + ')" >删除</a>&nbsp;&nbsp;';
							return htmlText;
						}
					}
				}
			];
			var oTable1 = TableManaged(json).init();
		}

		//跳转添加页面
		function toAddAuthDept() {
			window.location.href = contextPath + "/auth/authdept/toEditAuthDept.htm?orgCode=${orgCode}&operateType=1";
		}

		//删除部门
		function deleteAuthDept(deptId) {
			if (confirm("请确认是否删除该组织机构?")) {
				$.ajax({
					url: contextPath + "/auth/authdept/deleteAuthDept.json",
					type: "post",
					data: {deptId: deptId},
					async: false,
					success: function (data) {
						var msg = eval("(" + data + ")");
						$.Alert(msg.message,'',toAuthDeptList);
					},
					error: function () {
						$.Alert('服务异常，请稍后尝试!','',null);
					}
				});
			}
		}

		//返回上个页面
		function toAuthDeptList() {
			location.href = contextPath + "/auth/authdept/toAuthDeptList.htm?orgCode=${orgCode}";
		}
	</script>
</body>
</html>
